//
//  ExchangeRateToCurrencyTableViewCell.m
//  汇率换算
//
//  Created by king on 15/11/26.
//  Copyright © 2015年 king. All rights reserved.
//

#import "ExchangeRateToCurrencyTableViewCell.h"
#import "ExchangeRateConvert.h"

#define SCREENWIDTH [UIScreen mainScreen].bounds.size.width
#define SCREENHEIGHT [UIScreen mainScreen].bounds.size.height


@implementation ExchangeRateToCurrencyTableViewCell

#pragma mark - Method Custom Init
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createTableViewCell];
    }
    return self;
}
#pragma mark - Method createTableViewCell
- (void)createTableViewCell {
    self.toCurrencyLabel = [[UILabel alloc] init];
    self.toCurrencyLabel.backgroundColor = [UIColor clearColor];
    self.toCurrencyLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.toCurrencyLabel];
    
    self.currencyText = [[UITextField alloc] init];
    self.currencyText.backgroundColor = [UIColor clearColor];
    self.currencyText.textAlignment = NSTextAlignmentCenter;
    self.currencyText.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
    self.currencyText.font = [UIFont systemFontOfSize:13];
    
    [self addSubview:self.currencyText];
    
    self.convertedamountText = [[UITextField alloc] init];
    self.convertedamountText.backgroundColor = [UIColor clearColor];
    self.convertedamountText.font = [UIFont systemFontOfSize:22];
    self.convertedamountText.alpha = 0.5;
    [self addSubview:self.convertedamountText];
}
#pragma mark - Method layoutSubviews
- (void)layoutSubviews {
    [super layoutSubviews];
        self.toCurrencyLabel.frame = CGRectMake(0, 0, SCREENWIDTH/2, 50);
        self.currencyText.frame = CGRectMake(0, 50, SCREENWIDTH/2, 30);
        self.convertedamountText.frame = CGRectMake(SCREENWIDTH/2, 0, SCREENWIDTH/2, 80);
}
#pragma mark - Method 
- (void)setModel:(ExchangeRateConvertDetailModel *)model {
    if (_model != model) {
        _model = model;
    }
    self.toCurrencyLabel.text = [[ExchangeRateConvert shareExchangeRateConvert] selectDataFromExchangeRateConvertBaseKey:model.toCurrency];
    self.currencyText.text = [NSString stringWithFormat:@"1 %@=%f %@", [[ExchangeRateConvert shareExchangeRateConvert] selectDataFromExchangeRateConvertBaseKey:model.fromCurrency], model.currency, [[ExchangeRateConvert shareExchangeRateConvert] selectDataFromExchangeRateConvertBaseKey:model.toCurrency]];
    self.convertedamountText.text = [NSString stringWithFormat:@"%.2f", model.convertedamount];
}
#pragma mark - Method awakeFromNib
- (void)awakeFromNib {
    // Initialization code
}
#pragma mark - Method setSelected:animated:
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
